package com.gym.controller;

import com.alibaba.fastjson.JSONObject;
import com.gym.client.MemberClient;
import com.gym.pojo.Catsaletake;
import com.gym.pojo.Cattype;
import com.gym.vo.Caum;
import com.gym.vo.UserVo;
import com.gym.pojo.User;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@RestController
public class MemberController {

    @Resource
    private MemberClient memberClient;

    @RequestMapping("/listMem")//查询全部会员
    public List<UserVo> listMem(String name,Integer catId){
        return memberClient.listMem(name,catId);
    }

    @RequestMapping("/listMember")
    public JSONObject listMemBer(String name,Integer catId,int page,int limit){
        return memberClient.selMember(name,catId,page,limit);
    }

    @RequestMapping("/expireMem")//查询过期会员
    public List<UserVo> expireMem(String date,String time){
        return memberClient.expireMem(date,time);
    }

    @RequestMapping("/updMemStatic")
    public boolean updMemStatic(int memId) {
        return memberClient.updMemStatic(memId);
    }

    @RequestMapping("/listCat")
    public JSONObject listCat(String name){
        if (name==null||name==""||name.equals("")||name.equals("undefined")){
            name="";
        }
        List<Cattype> list=memberClient.listCat(name);
        JSONObject json=new JSONObject();
        json.put("code",0);
        json.put("msg","");
        json.put("count",list.size());
        json.put("data",list);
        return json;
    }

    @RequestMapping("/delCatById")
    public boolean delCatById(int catId) {
        return memberClient.delCatById(catId);
    }

    @RequestMapping("/selCatByMem")
    public boolean selCatByMem(int catId) {
        return memberClient.selCatByMem(catId);
    }

    @RequestMapping("/updCatById")
    public boolean updCatById(@RequestBody Cattype cat) {
        return memberClient.updCatById(cat);
    }

    @RequestMapping("/insCat")
    public boolean insCat(@RequestBody Cattype cat) {
        return memberClient.insCat(cat);
    }

    @RequestMapping("/insCatSaleTake")
    public boolean insCatSaleTake(@RequestBody Catsaletake cst){
        return memberClient.insCatSaleTake(cst);
    }
    @RequestMapping("/insertMem")
    public boolean inMem(@RequestBody Caum caum){
        return memberClient.inMem(caum);
    }

    @RequestMapping("/selCatSelaTake")
    public JSONObject selCatSelaTake(String date, String time,int page,int limit){
        return memberClient.selCatSelaTake(date,time,page,limit);
    }

    @RequestMapping("/selUserById")
    public UserVo selUserById(int userId) {
        return memberClient.selUserById(userId);
    }

    @RequestMapping("/continuous")
    public boolean continuous(@RequestBody Caum caum){
        return memberClient.continuous(caum);
    }
}
